import {
  extend,
  type ExtendArg,
} from '@/library/libs/extend'

/**
 * @description 浅合并
 * @param {ExtendArg[]} args 第一个为目标对象, 其余的为要合并的对象
 * @returns 目标对象
 * @example
 * ------------------------------
 * let obj1 = { a: {b: 'b', f: 'f'}, c: 'c'}
 * let obj2 = { a: {b: 'bb', d: 'd'}, c: [1, 2, 3] }
 * // => {a: {b: 'bb', d: 'd'}, c: [1, 2, 3]}
 */
export function shallowExtend(...args: ExtendArg[]): ExtendArg {
  return extend(false, ...args)
}

/**
 * @description 深度合并
 * @param {ExtendArg[]} args 第一个为目标对象, 其余的为要合并的对象
 * @returns 目标对象
 * @example
 * ------------------------------
 * let obj1 = { a: {b: 'b', f: 'f'}, c: 'c'}
 * let obj2 = { a: {b: 'bb', d: 'd'}, c: [1, 2, 3] }
 * // => {a: {b: 'bb', d: 'd', f: 'f'}, c: [1, 2, 3]}
 */
export function deepExtend(...args: ExtendArg[]): ExtendArg {
  return extend(true, ...args)
}
